<?php
/*************************************************************************************
   Copyright notice

   This script uses some code parts of the glossary module for phpwcms (c) Oliver Georgi
   (c) 2002-2009 Oliver Georgi (oliver@phpwcms.de) // All rights reserved.

   This script uses some code parts from bmcatalog module
   (c) 2010 Benjamin Matzmorr, www.etype.de

   (c) 2012 webrealisierung gmbh, www.webrealisierung.ch
   Catalogue Module V 1.0.0  -  Date: 2012-06-01

   The GNU General Public License can be found at http://www.gnu.org/copyleft/gpl.html
   A copy is found in the textfile GPL.txt and important notices to the license
   from the author is found in LICENSE.txt distributed with these scripts.

   This script is distributed in the hope that it will be useful, but WITHOUT ANY
   WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A
   PARTICULAR PURPOSE.  See the GNU General Public License for more details.

   This copyright notice MUST APPEAR in all copies of the script!
*************************************************************************************/
// ----------------------------------------------------------------
// obligate check for phpwcms constants
if (!defined('PHPWCMS_ROOT')) {
   die("You Cannot Access This Script Directly, Have a Nice Day.");
}
// ----------------------------------------------------------------

//js and css head
$BE['HEADER']['optionselect.js']		= getJavaScriptSourceLink('include/inc_js/optionselect.js');
$BE['HEADER'][] = '<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
<link rel="stylesheet" type="text/css" href="'.MODULE_CTG_DIR.'template/backend/msdropdown/dd.css">
<script type="text/javascript" src="'.MODULE_CTG_DIR.'template/backend/msdropdown/js/jquery.dd.js"></script>
<link rel="stylesheet" type="text/css" href="'.MODULE_CTG_DIR.'template/backend/css/custom/jquery-ui-1.8.19.custom.css">
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/jquery-ui.min.js"></script>
<script type="text/javascript" src="'.MODULE_CTG_DIR.'template/backend/jqueryFileTree/jqueryFileTree.js"></script>
<link rel="stylesheet" type="text/css" href="'.MODULE_CTG_DIR.'template/backend/jqueryFileTree/jqueryFileTree.css">';

//google maps api is only loaded on demand
//<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>

//get strings for autocompleter js
$cat_sql = "SELECT ctge_tags FROM " . DB_PREPEND . "phpwcms_mod_catalogue_entry WHERE ctge_status!=9 group by ctge_tags ";
$data = _dbQuery($cat_sql);
$tmp_tags_all = array();
if (count($data)>0) {
  foreach ($data as $row) {
  $tmp_tags = explode("|", trim($row["ctge_tags"], "|") );
  $tmp_tags_all = array_merge($tmp_tags_all, array_map('trim', $tmp_tags));
  }
  natcasesort($tmp_tags_all);
  $plugin['category_tags'] = '"' . implode( '", "',  array_unique($tmp_tags_all)) . '"';
}
$country_sql = "SELECT ctge_address_country FROM " . DB_PREPEND . "phpwcms_mod_catalogue_entry group by ctge_address_country ";
$country_data = _dbQuery($country_sql);
$tmp_country_all = array();
if (count($country_data)>0) {
  foreach ($country_data as $row) {
  $tmp_country = trim($row["ctge_address_country"]);
  if($tmp_country) $tmp_country_all[] = $tmp_country;
  }
  natcasesort($tmp_country_all);
  $plugin['country_tags'] = '"' . implode( '", "', array_unique($tmp_country_all)) . '"';
}

if ($plugin['data']['ctge_images'][0]['active'] == 1) {
  $plugin['data']['ctge_gallery'] = 0 ;
} else {
  $plugin['data']['ctge_gallery'] = 1 ;
}

//js document ready
$BE['HEADER'][] = "
<script type='text/javascript'>
<!--

  $(document).ready(function() {

    //tabs
    $( '#tabs' ).tabs({
      select: function(event, ui) {
        if(ui.index ==2) {
          if (apiloaded == false && document.getElementById('ctg_lat').value) {
            loadAPI();
          }
        }
      }
    });

    //autocompleter
    var availableCountries = [ ".$plugin['country_tags']." ];
		var availableTags = [ ".$plugin['category_tags']." ];
    //tags multi
		$( '#ctg_tags' )
			.bind( 'keydown', function( event ) {
				if ( event.keyCode === $.ui.keyCode.TAB &&
						$( this ).data( 'autocomplete' ).menu.active ) {
					event.preventDefault();
				}
			})
			.autocomplete({
				minLength: 0,
				source: function( request, response ) {
					response( $.ui.autocomplete.filter(
						availableTags, extractLast( request.term ) ) );
				},
				focus: function() {
					return false;
				},
				select: function( event, ui ) {
					var terms = split( this.value );
					terms.pop();
					terms.push( ui.item.value );
					terms.push( '' );
					this.value = terms.join( ', ' );
					return false;
				}
			});
    //country only one
    $( '#ctg_country' ).autocomplete({
			source: availableCountries
		});

    //filetree
    $('#filetree').fileTree({
      root: '../../../../catalog_images/',
      script: '".MODULE_CTG_DIR."template/backend/jqueryFileTree/connectors/jqueryFileTree.php',
      expandSpeed: 500,
      collapseSpeed: 500,
      folderEvent: 'click',
      expanded: '../../../../".$plugin['data']['ctge_images'][1]['root']."'
    }, function(file) {
        $('#ctg_gallery_root').val(file.substr(12));
        $('#ctg__root').val(file.substr(12));
    });

    $('div.desc').hide();
    $('#ctg_gallery' + ".$plugin['data']['ctge_gallery'].").show();
    $('input[name$=\'ctg_gallery\']').click(function() {
        var test = $(this).val();

        $('div.desc').hide();
        $('#ctg_gallery' + test).show();
    });

    //ms dropdown
    $('#ctg_marker').msDropDown({visibleRows:7, rowHeight:40});

  });

  //autocompleter multi
  function split( val ) {
		return val.split( /,\s*/ );
	}
	function extractLast( term ) {
		return split( term ).pop();
	}

//-->
</script>".LF;

//js google maps
$BE['HEADER'][] = '<script type="text/javascript">
<!--

  var geocoder;
	var map;
	var marker;
  var apiloaded = false;

  //load maps api only on demand
  function loadAPI()
  {
    var script = document.createElement("script");
    script.src = "http://maps.google.com/maps/api/js?sensor=false&callback=initializemap";
    script.type = "text/javascript";
    document.body.appendChild(script);
    apiloaded = true;
  }

  function codeAddress()
  {
    if (apiloaded == false) {
      loadAPI();
      GeocodeAddress();
    } else {
      GeocodeAddress();
    }
  }

  //geocode address
  function GeocodeAddress()
  {
    geocoder = new google.maps.Geocoder();
    if (document.getElementById("ctg_country").value) {
      var address_address = "";
      if (document.getElementById("ctg_address").value) {
        address_address = document.getElementById("ctg_address").value + "+";
      }
      var address_zip = "";
      if (document.getElementById("ctg_zip").value) {
        address_zip = document.getElementById("ctg_zip").value + "+";
      }
      var address_city = "";
      if (document.getElementById("ctg_city").value) {
        address_city = document.getElementById("ctg_city").value + "+";
      }
      var address = address_address + address_zip + address_city + document.getElementById("ctg_country").value;
      if (geocoder) {
        geocoder.geocode( { "address": address}, function(results, status) {
          if (status == google.maps.GeocoderStatus.OK) {
      			document.getElementById("ctg_lat").value=results[0].geometry.location.lat();
            document.getElementById("ctg_lng").value=results[0].geometry.location.lng();
            initializemap()
          } else {
            alert("Check address: Geocode not successful. error: " + status);
          }
        });
      }
    } else {
      alert("Country required");
    }
  }

  //initialize map
  function initializemap()
  {
		lat=document.getElementById("ctg_lat").value;
		lng=document.getElementById("ctg_lng").value;
		if ((lat!=0 && lng!=0)) {
			var latlng= new google.maps.LatLng(lat, lng);
			var myOptions = {
			  zoom: 14,
			  center: latlng,
			  mapTypeId: google.maps.MapTypeId.ROADMAP
			};
			map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
			document.getElementById("map_canvas").style.display = "block";
			marker = new google.maps.Marker({
					position: latlng,
					map: map,
          title:"drag+drop me",
          draggable: true
				});
        google.maps.event.addListener(marker, "dragend", function() {
          document.getElementById("ctg_lng").value = marker.getPosition().lng() ;
          document.getElementById("ctg_lat").value = marker.getPosition().lat() ;
        });
		}
  }

//-->
</script>'.LF;

//css document
$BE['HEADER'][] = "<style type='text/css'>
<!--
#tabs>div { height:550px; }
.formarticlecontent { background:#F3F5F8;border-top:1px solid #92A1AF;border-bottom:1px solid #92A1AF;margin:0 0 5px 0;padding:10px 8px 15px 8px; }
.w50 { width:50px; }
.w75 { width:75px; }
.w200 { width:200px; }
.w300 { width:300px; }
.w350 { width:350px; }
.w400 { width:400px; }
.tabImgDivRadio { width:100%;border-bottom: 1px dotted #92A1AF;padding:5px}
.tabImgDivRadio label { margin-right:30px; }
.desc { margin-top:10px; }
.tabImgDivThumbs { width:460px;height:200px;overflow:auto;margin:10px 0 10px 10px; }
//-->
</style>".LF;





?>

<form action="<?php echo MODULE_HREF ?>&amp;edit=<?php echo $plugin['data']['ctge_id'] ?>" method="post" name="articlecontent" class="formarticlecontent" onsubmit="selectAllOptions(this.ctg_images);">
<input type="hidden" name="ctg_id" value="<?php echo $plugin['data']['ctge_id'] ?>" />
<table border="0" cellpadding="0" cellspacing="0" width="100%" summary="">

	<tr>
		<td align="right" class="chatlist"><?php echo $BL['be_cnt_last_edited']  ?>:&nbsp;</td>
		<td class="v10"><?php echo html_specialchars(date($BL['be_fprivedit_dateformat'], strtotime($plugin['data']['ctge_changed']))) ?></td>
	</tr>

	<?php if(!empty($plugin['data']['ctge_created'])) { ?>

	<tr>
		<td align="right" class="chatlist"><?php echo $BL['be_fprivedit_created']  ?>:&nbsp;</td>
		<td class="v10"><?php echo html_specialchars(date($BL['be_fprivedit_dateformat'], strtotime($plugin['data']['ctge_created']))) ?></td>
	</tr>

	<?php } ?>

	<tr><td colspan="2"><img src="img/leer.gif" alt="" width="1" height="10" /></td></tr>

	<tr>
		<td align="right" class="chatlist"><?php echo $BLM['ctg_title'] ?>*:&nbsp;</td>
		<td><input type="text" name="ctg_title" id="ctg_title" value="<?php echo html_specialchars($plugin['data']['ctge_title']) ?>" class="w400 f11b<?php

		//error class
		if(!empty($plugin['error']['ctge_title'])) echo ' errorInputText';

		?>" size="30" maxlength="255" /></td>
	</tr>

	<tr><td colspan="2"><img src="img/leer.gif" alt="" width="1" height="5" /></td></tr>

	<tr>
		<td align="right" class="chatlist"><?php echo $BLM['ctg_title2'] ?>:&nbsp;</td>
		<td><input type="text" name="ctg_title2" id="ctg_title2" value="<?php echo html_specialchars($plugin['data']['ctge_title2']) ?>" class="w400 f11b" size="30" maxlength="255" /></td>
	</tr>

	<tr><td colspan="2"><img src="img/leer.gif" alt="" width="1" height="10" /></td></tr>
  <!-- catalogs -->
	<tr>
		<td align="right" class="chatlist" valign="top"><?php echo $BLM['cp_catalogs']; ?>&nbsp;<div style="padding:3px;font-size:7pt;"><?php echo $BLM['entry_multi']; ?></div></td>
		<td align="left" class="v10">

<?php
    $sql = "SELECT * FROM ".DB_PREPEND."phpwcms_mod_catalogue_catalog WHERE ctgc_status!=9 ORDER BY ctgc_name ASC";
    $data = _dbQuery($sql);
	$xml="";
  foreach($data as $row) {
	 		$xml .=	'<option value="'.$row['ctgc_id'].'"';
	 		if (in_array($row['ctgc_id'], $plugin['data']['ctge_catalogid'])) {
          $xml  .= ' selected="selected"';
        }
      $xml .= '>'.$row['ctgc_name'];
        if ($row['ctgc_status']==0)  $xml .= ' ['.$BLM['disabled'].']';
      $xml .= '</option>';
	}
 ?>

    <select name="ctg_catalogid[]" id="ctg_catalogid" class="w400 f11 listrow" size="8" multiple="multiple">
     <?php echo $xml; ?>
    </select>
	</tr>
  <!-- end catalogs -->

	<tr><td colspan="2"><img src="img/leer.gif" alt="" width="1" height="10" /></td></tr>

	<tr>
    <td colspan="2">
      <div id="tabs">

	<ul>
		<!-- li><a href="#tabs-1"><?php echo $BLM['ctg_tabs_descr'] ?>&nbsp;</a></li -->
		<li><a href="#tabs-2"><?php echo $BLM['ctg_tabs_images'] ?>&nbsp;</a></li>
		<li><a href="#tabs-3"><?php echo $BLM['ctg_tabs_file'] ?>&nbsp;</a></li>
		<li><a href="#tabs-4"><?php echo $BLM['ctg_tabs_address'] ?>&nbsp;</a></li>
    <li><a href="#tabs-5"><?php echo $BLM['ctg_tabs_tags'] ?>&nbsp;</a></li>
	</ul>

  <!-- descriptions -->
        <!-- div id="tabs-1"></div -->
  <!-- end descriptions -->
  <!-- images -->

        <div id="tabs-2">

<div class="tabImgDivRadio">
  <input type="radio" name="ctg_gallery" id="R_01" value="0" <?php is_checked(1, $plugin['data']['ctge_images'][0]['active']); ?> /><label for="R_01" class="chatlist checkbox"><?php echo $BLM['ctg_gal0'] ?></label>
  <input type="radio" name="ctg_gallery" id="R_02" value="1" <?php is_checked(1, $plugin['data']['ctge_images'][1]['active']); ?> /><label for="R_02" class="chatlist checkbox"><?php echo $BLM['ctg_gal1'] ?></label>
</div>

<div id="ctg_gallery0" class="desc">
          <table cellpadding="0" cellspacing="0" border="0" width="100%">

          	<tr>
            	<td width="100" align="right" valign="top" class="chatlist tdtop4"><?php echo $BLM['ctg_image'] ?>:&nbsp;</td>
          		<td valign="top">
          		<select name="ctg_images[]" size="8" multiple="multiple" class="f11 w350" id="ctg_images"><?php
          		$img_count = isset($plugin['data']['images']) && is_array($plugin['data']['images']) ? count($plugin['data']['images']) : 0;
          		$img_thumbs = '';
          		$plugin['data']['img_captions']=array();
//          $zoom_images= '';
          $imgx = 0;
          		if($img_count) {

          			// browse images and list available
          			// will be visible only when aceessible

          			foreach($plugin['data']['images'] as $key => $value) {

 //         				$zoom_images= $value['zoom'];

          				// 0   :1       :2   :3        :4    :5     :6      :7       :8
          				// dbid:filename:hash:extension:width:height:caption:position:zoom
          				$thumb_image = get_cached_image(
          								array(	"target_ext"	=>	$plugin['data']['images'][$key]['f_ext'],
          										"image_name"	=>	$plugin['data']['images'][$key]['f_hash'] . '.' . $plugin['data']['images'][$key]['f_ext'],
          										"thumb_name"	=>	md5(	$plugin['data']['images'][$key]['f_hash'].
          																	$phpwcms["img_list_width"].
          																	$phpwcms["img_list_height"].
          																	$phpwcms["sharpen_level"]
          																)
          									  )
          									);

          				if($thumb_image != false) {

          					// image found
          					echo '<option value="' . $plugin['data']['images'][$key]['f_id'] . '">';
          					$img_name = html_specialchars($plugin['data']['images'][$key]['f_name']);
          					echo $img_name . '</option>'.LF;

          					if($imgx == 4) {
          						$img_thumbs .= '<br /><img src="img/leer.gif" alt="" border="0" width="1" height="2" /><br />';
          						$imgx = 0;
          					}
          					if($imgx) {
          						$img_thumbs .= '<img src="img/leer.gif" alt="" border="0" width="2" height="1" />';
          					}
          					$img_thumbs .= '<img src="'.PHPWCMS_IMAGES . $thumb_image[0] .'" border="0" '.$thumb_image[3].' alt="'.$img_name.'" title="'.$img_name.'" />';

          					$plugin['data']['img_captions'][] = html_specialchars($plugin['data']['images'][$key]['caption']);

          					$imgx++;
          				}	// thumb ok

          			}	//for each

          		}	// got images

          		?></select>
              </td>
              <td valign="top"><img src="img/leer.gif" alt="" width="5" height="1" /></td>
              <td valign="top">
          		  <a href="#" title="<?php echo $BL['be_cnt_openimagebrowser'] ?>" onclick="tmt_winOpen('filebrowser.php?opt=5&amp;target=nolist','imageBrowser','width=380,height=300,left=8,top=8,scrollbars=yes,resizable=yes',1);return false;"><img src="img/button/open_image_button.gif" alt="" width="20" height="15" border="0" /></a>
          		  <br /><img src="img/leer.gif" alt="" width="1" height="4" /><br /><a href="#" title="<?php echo $BL['be_cnt_sortup'] ?>" onclick="moveOptionUp(img_field);return false;"><img src="img/button/image_pos_up.gif" alt="" width="10" height="9" border="0" /></a><a href="#" title="<?php echo $BL['be_cnt_sortdown'] ?>" onclick="moveOptionDown(img_field);return false;"><img src="img/button/image_pos_down.gif" alt="" width="10" height="9" border="0" /></a>
          		  <br /><img src="img/leer.gif" alt="" width="1" height="4" /><br /><a href="#" onclick="removeSelectedOptions(img_field);return false;" title="<?php echo $BL['be_cnt_delimage'] ?>"><img src="img/button/del_image_button1.gif" alt="" width="20" height="15" border="0" /></a>

          		</td>
            </tr>

          	<?php

          		if($img_thumbs) {
          			echo '
            <tr>
                <td colspan="2"><div class="tabImgDivThumbs">'.$img_thumbs.'</div></td>
                <td colspan="2"></td>
            </tr>';
          		}
          	?>
	    <tr><td colspan="2"><img src="img/leer.gif" alt="" width="1" height="10" /></td></tr>
          	<tr>
          		<td align="right" valign="top" class="chatlist tdtop4"><?php echo $BLM['ctg_image_caption'] ?>:&nbsp;</td>
          		<td colspan="3" valign="top"><textarea name="ctg_caption" id="ctg_caption" cols="40" rows="8" wrap="off" class="f11 w350"><?php echo implode(' '.LF, $plugin['data']['img_captions']) ?></textarea></td>
          	</tr>
          </table>
</div>

<div id="ctg_gallery1" class="desc">
  <table cellpadding="0" cellspacing="0" border="0" width="100%">
    <tr>
      <td width="100" align="right" class="chatlist"><?php echo $BLM['ctg_folder'] ?>:&nbsp;</td>
      <td><input type="text" name="ctg__root" id="ctg__root" value="<?php echo $plugin['data']['ctge_images'][1]['root']; ?>" class="f11 w350" size="80" disabled="disabled" />
      <input type="hidden" name="ctg_gallery1_root" id="ctg_gallery_root" value="<?php echo $plugin['data']['ctge_images'][1]['root']; ?>" /></td>
    </tr>
    <tr>
      <td>&nbsp;</td>
      <td><div id="filetree"></div></td>
    </tr>
    <tr><td colspan="2"><img src="img/leer.gif" alt="" width="1" height="10"></td></tr>
    <tr>
      <td align="right" class="chatlist" valign="top"><img src="<?php echo MODULE_CTG_DIR ?>img/icon_info.gif" border="0" alt="Help" />&nbsp;</td>
      <td class="chatlist"><?php echo $BLM['ctg_img_info'] ?></td>
    </tr>
  </table>
</div>

        </div>
  <!-- end images -->
  <!-- files -->

        <div id="tabs-3">
          <table cellpadding="0" cellspacing="0" border="0" width="100%">
          	<tr>
          	  <td width="100" align="right" valign="top" class="chatlist"><img src="img/leer.gif" alt="" width="1" height="13"><?php echo $BLM['ctg_file'] ?>:&nbsp;</td>
          	  <td valign="top"><table border="0" cellpadding="0" cellspacing="0" summary="">
          		<tr>
          		  <td valign="top"><input type="text" name="ctg_file_name" id="ctg_file_name" value="<?php echo html_specialchars($plugin['data']['file'][1]) ?>" class="w300 f11" size="80" />
          				<input type="hidden" name="ctg_file_id" id="ctg_file_id" value="<?php echo html_specialchars($plugin['data']['file'][0]) ?>" />
          		  </td>
          		  <td valign="top"><img src="img/leer.gif" alt="" width="5" height="1"></td>                                           <!-- browser_file.php //-->
          		  <td valign="top"><a href="javascript:;" title="<?php echo $BL['be_cnt_openfilebrowser'] ?>" onclick="tmt_winOpen('filebrowser.php?opt=9&amp;target=nolist','imageBrowser','width=380,height=300,left=8,top=8,scrollbars=yes,resizable=yes,status=yes',1)"><img src="img/button/open_image_button.gif" alt="" width="20" height="15" border="0"></a><br />
          		    <a href="javascript:;"  onclick="addFile();return false;" title="<?php echo $BL['be_cnt_delfile'] ?>"><img src="img/button/del_image_button1.gif" alt="" width="20" height="15" border="0"></a></td>
          		</tr>
          	 </table></td>
            </tr>

          	<tr>
          	 		<td  align="right" class="chatlist"><?php echo $BLM['ctg_file_caption'] ?>:&nbsp;</td>
          	 		<td><input type="text" name="ctg_file_caption" id="ctg_file_caption" value="<?php echo html_specialchars($plugin['data']['file'][6]) ?>" class="w300" /></td>
          	</tr>
          </table>
        </div>
  <!-- end files -->

  <!-- google maps -->
        <div id="tabs-4">
          <table cellpadding="0" cellspacing="0" border="0" width="100%">

            <tr>
            	<td width="100" align="right" class="chatlist"><?php echo $BLM['ctg_address'] ?>:&nbsp;</td>
            	<td><input type="text" name="ctg_address" id="ctg_address" value="<?php echo html_specialchars($plugin['data']['ctge_address_address']) ?>" class="w350 f11b" size="30" maxlength="128" /></td>
            </tr>

          	<tr><td colspan="2"><img src="img/leer.gif" alt="" width="1" height="10" /></td></tr>

          	<tr>
          		<td align="right" class="chatlist"><?php echo $BLM['ctg_zip'] ?>:&nbsp;</td>
          		<td><table border="0" cellpadding="0" cellspacing="0" summary="" width="355">
                <tr>
          		    <td><input type="text" name="ctg_zip" id="ctg_zip" value="<?php echo html_specialchars($plugin['data']['ctge_address_zip']) ?>" class="w75 f11b" size="5" maxlength="20" /></td>
                  <td align="right" class="chatlist">&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $BLM['ctg_city'] ?>:&nbsp;<input type="text" name="ctg_city" id="ctg_city" value="<?php echo html_specialchars($plugin['data']['ctge_address_city']) ; ?>" class="w200 f11b" size="30" maxlength="128" /></td>
          		  </tr>
          		</table></td>
          	</tr>

          	<tr><td colspan="2"><img src="img/leer.gif" alt="" width="1" height="10" /></td></tr>

          	<tr>
          		<td align="right" class="chatlist"><?php echo $BLM['ctg_country'] ?>*:&nbsp;</td>
          		<td><input type="text" name="ctg_country" id="ctg_country" value="<?php echo html_specialchars($plugin['data']['ctge_address_country']) ; ?>" class="w350 f11b" size="30" maxlength="128" /></td>
          	</tr>
	          <tr><td colspan="2"><img src="img/leer.gif" alt="" width="1" height="10" /></td></tr>
          	<tr>
          		<td align="right" class="chatlist">&nbsp;</td>
          		<td class="chatlist"><input type="button" name="ctg_geocode" id="ctg_geocode" value="<?php echo $BLM['ctg_geocode_now'] ?>" onclick="codeAddress();" />
          		&nbsp;<?php echo $BLM['ctg_geocode'] ?></td>
          	</tr>

          	<tr>
              <td align="right">&nbsp;</td>
          		<td class="chatlist"><input type="text" name="ctg_lng" id="ctg_lng" value="<?php
          			if (!isempty($plugin['data']['ctge_address_long'])) {
          				echo html_specialchars($plugin['data']['ctge_address_long']) ;
          			} else {
          				echo "0";
          			}
          			?>" class="w200 f11b" size="30" maxlength="128" />&nbsp;<?php echo $BLM['ctg_coordinates_lng'] ?></td>
            </tr>

          	<tr>
              <td align="right">&nbsp;</td>
          		<td class="chatlist"><input type="text" name="ctg_lat" id="ctg_lat" value="<?php
          			if (!isempty($plugin['data']['ctge_address_lat'])) {
          				echo html_specialchars($plugin['data']['ctge_address_lat']) ;
          			} else {
          				echo "0";
          			}
          			?>" class="w200 f11b" size="30" maxlength="128" />&nbsp;<?php echo $BLM['ctg_coordinates_lat'] ?><br>
          		</td>
            </tr>

          	<tr><td colspan="2"><img src="img/leer.gif" alt="" width="1" height="10" /></td>

          	<tr>
          		<td align="right" class="chatlist"><?php echo $BLM['ctg_show_in_googlemaps'] ?>:&nbsp;</td>
          		<td><table border="0" cellpadding="0" cellspacing="0" summary="" width="355">
          			<tr>
          				<td><input type="checkbox" name="ctg_show_map" id="ctg_show_map" value="1"<?php is_checked($plugin['data']['ctge_address_show_map'], 1) ?> /></td>
          				<td><label for="ctg_show_map" class="chatlist"><?php echo $BLM['ctg_act'] ?></label></td>
                  <td align="right" class="chatlist">&nbsp;&nbsp;&nbsp;<?php echo $BLM['ctg_marker'] ?>:&nbsp;</td>
                  <td align="right"><select name="ctg_marker" id="ctg_marker" class="w200 f11b"><?php

            	echo '     <option value="0.gif">'.$BL['be_admin_tmpl_default'].'</option>'.LF;

              //$csslist = get_tmpl_files($phpwcms['modules'][$module]['dir'].'template/map-icons-collection-2.0/icons','jpg,gif,png');
              $csslist = get_tmpl_files($phpwcms['modules'][$module]['dir'].'template/map-icons','jpg,gif,png');
              if(is_array($csslist) && count($csslist)) {
              	foreach($csslist as $valcss) {
              		$selected_css = (isset($plugin['data']['ctge_address_marker']) && $valcss == $plugin['data']['ctge_address_marker']) ? ' selected="selected"' : '';
              		$valcss = html_specialchars($valcss);
              		//if ($valcss != '0.gif') echo '      <option value="' . $valcss . '"' . $selected_css . ' title="'.$phpwcms['modules'][$module]['dir'].'template/map-icons-collection-2.0/icons/'.$valcss.'">' . $valcss . '</option>' . LF;
              		if ($valcss != '0.gif') echo '      <option value="' . $valcss . '"' . $selected_css . ' title="'.$phpwcms['modules'][$module]['dir'].'template/map-icons/'.$valcss.'">' . $valcss . '</option>' . LF;
              	}
              }
          ?></select></td>

          			</tr>
          		</table></td>
          	</tr>

          	<tr><td colspan="2"><img src="img/leer.gif" alt="" width="1" height="10" /></td></tr>

          	<tr><td colspan="2"><div id="map_canvas" style="width:490px; height:300px;"></div></td></tr>

          	<tr><td colspan="2"><img src="img/leer.gif" alt="" width="1" height="10" /></td></tr>
          	<tr>
              <td align="right" class="chatlist" valign="top"><img src="<?php echo MODULE_CTG_DIR ?>img/icon_info.gif" border="0" alt="Help" />&nbsp;</td>
              <td class="chatlist"><?php echo $BLM['ctg_addr_info'] ?></td>
            </tr>


          </table>
        </div>
  <!-- end google maps -->

  <!-- tags -->

        <div id="tabs-5">
          <table cellpadding="0" cellspacing="0" border="0" width="100%">
          	<tr>
          	  <td width="100" align="right" valign="top" class="chatlist"><img src="img/leer.gif" alt="" width="1" height="13"><?php echo $BLM['ctg_tags'] ?>:&nbsp;</td>
          	  <td valign="top"><div class="demo">

<div class="ui-widget">
<textarea name="ctg_tags" id="ctg_tags" class="w350" cols="30" rows="5"><?php echo html_specialchars($plugin['data']['ctge_tags']); ?></textarea>
</div>

</div></td>
            </tr>

          	<tr>
          	 		<td  align="right"></td>
          	 		<td></td>
          	</tr>

          </table>
          <div style="width:90%;position:absolute;bottom:20px;">
          	<table cellpadding="0" cellspacing="0" border="0" width="100%">
          	<tr>
              <td width="100" align="right" class="chatlist" valign="top"><img src="<?php echo MODULE_CTG_DIR ?>img/icon_info.gif" border="0" alt="Help" />&nbsp;</td>
              <td class="chatlist"><?php echo $BLM['ctg_tags_info'] ?></td>
            </tr>
          </table>
          </div>
        </div>
  <!-- end tags -->

      </div>
      <!-- end tabs -->
    </td>
  </tr>

	<tr><td colspan="2"><img src="img/leer.gif" alt="" width="1" height="10" /></td></tr>

  <tr>
    <td colspan="2" align="left" class="chatlist"><?php echo $BLM['ctg_text'] ?>&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2" align="left"><?php

          		$wysiwyg_editor = array(
          			'value'		=> $plugin['data']['ctge_text'],
          			'field'		=> 'ctg_text',
          			'height'	=> '200px',
          			'width'		=> '520px',
          			'rows'		=> '10',
          			'editor'	=> $_SESSION["WYSIWYG_EDITOR"],
          			'lang'		=> 'en'
          		);
          		include(PHPWCMS_ROOT.'/include/inc_lib/wysiwyg.editor.inc.php');

  ?></td>
  </tr>
  <tr><td colspan="2"><img src="img/leer.gif" alt="" width="1" height="10" /></td></tr>
  <tr>
    <td align="left" class="chatlist"><?php echo $BLM['ctg_text2'] ?>&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2" align="left"><div id="wysi2"><?php

          		$wysiwyg_editor = array(
          			'value'		=> $plugin['data']['ctge_text2'],
          			'field'		=> 'ctg_text2',
          			'height'	=> '300px',
          			'width'		=> '520px',
          			'rows'		=> '10',
          			'editor'	=> $_SESSION["WYSIWYG_EDITOR"],
          			'lang'		=> 'en'
          		);
          		include(PHPWCMS_ROOT.'/include/inc_lib/wysiwyg.editor.inc.php');

  ?></div></td>
  </tr>

	<tr><td colspan="2"><img src="img/leer.gif" alt="" width="1" height="10" /></td></tr>

  <!-- owner userID-->
  <tr><td colspan="2" class="rowspacer0x7"><img src="img/leer.gif" alt="" width="1" height="1" /></td></tr>
	<tr><td colspan="2"><img src="img/leer.gif" alt="" width="1" height="10" /></td></tr>

   <tr>
        <td align="right" class="chatlist"><?php echo $BLM['entry_uid']; ?>&nbsp;&nbsp;</td>
        <td align="left">

         <table border="0" cellpadding="0" cellspacing="0" summary="">
            <tr>
               <td><?php
            $outputenabled = "";
            $outputdisabled = "";
            $u_sql = "SELECT usr_id, usr_name, usr_login, usr_admin FROM ".DB_PREPEND."phpwcms_user WHERE usr_aktiv=1 ORDER BY usr_admin DESC, usr_name";
            if($u_result = mysql_query($u_sql, $db)) {
               while($u_row = mysql_fetch_row($u_result)) {
                  $outputenabled .= '<option value="'.$u_row[0].'"';
                  if (
                     $u_row[0] == $plugin['data']['ctge_userId'] ||
                      ( $plugin['data']['ctge_userId'] == 0 &&
                        $u_row[0] == $_SESSION['wcs_user_id']
                      )
                   )
                  {
                    $outputenabled .= ' selected';
                    $outputdisabled = html_specialchars(($u_row[1]) ? $u_row[1] : $u_row[2]);
                  }
                  if(intval($u_row[3])) {
                    $outputenabled .= ' style="background-color: #FFC299;"';
                    $outputdisabled .='" style="background-color: #FFC299;width:250px;';
                  }
                  $outputenabled .= '>'.html_specialchars(($u_row[1]) ? $u_row[1] : $u_row[2]).'</option>'."\n";
               }
               mysql_free_result($u_result);
            }
 ?><select name="ctge_userId" id="ctge_userId" style="width: 250px" class="f11b"><?php echo $outputenabled; ?></select>

            </td>
            <td>&nbsp;&nbsp;</td>
            <td bgcolor="#FFC299"><img src="img/leer.gif" alt="" width="15" height="10" /></td>
            <td class="chatlist">&nbsp;<?php echo $BL['be_article_adminuser'] ?></td>
            </tr></table>

      </td>
   </tr>
  <!-- end owner userID-->

	<tr><td colspan="2"><img src="img/leer.gif" alt="" width="1" height="10" /></td></tr>



		<tr>
			<td align="right" class="chatlist"><?php echo $BL['be_ftptakeover_status'] ?>:&nbsp;</td>
			<td><table border="0" cellpadding="0" cellspacing="0" summary="">
				<tr>
						<td><input type="checkbox" name="ctg_status" id="ctg_status" value="1"<?php is_checked($plugin['data']['ctge_status'], 1) ?> /></td>
					<td><label for="ctg_status"><?php echo $BL['be_cnt_activated'] ?></label></td>
				</tr>
			</table></td>
	</tr>

	<tr><td colspan="2"><img src="img/leer.gif" alt="" width="1" height="10" /></td></tr>

	<tr>
		<td>&nbsp;</td>
		<td>
			<input type="submit" name="submit" value="<?php echo empty($plugin['data']['ctge_id']) ? $BL['be_admin_fcat_button2'] : $BL['be_article_cnt_button1'] ?>" class="button10" />
			<input type="submit" name="save" value="<?php echo $BL['be_article_cnt_button3'] ?>" class="button10" />
			&nbsp;&nbsp;&nbsp;&nbsp;
			<input type="button" name="close" value="<?php echo $BL['be_admin_struct_close'] ?>" class="button10" onclick="location.href='<?php echo decode_entities(MODULE_HREF) ?>';return false;" />
		</td>
	</tr>

</table>
</form>

<script type="text/javascript">
<!--

	var img_field = getObjectById('ctg_images');

function openImageFileBrowser(image_number) {
	tmt_winOpen('filebrowser.php?opt=8&target=nolist&entry_id='+image_number,'imageBrowser','width=380,height=300,left=8,top=8,scrollbars=yes,resizable=yes',1);
	return false;
}

function addFile(file_id, file_name) {
	if(file_id == null) file_id=0;
	if(file_name == null) file_name='';
	getObjectById('ctg_file_id').value = file_id;
	getObjectById('ctg_file_name').value = file_name;
}

//-->
</script>